<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 100px;
            height: 100px;
            background-color: #f00;
        }
    </style>
</head>
<body>
    <input type="text" id="txt" class="txt aa bb cc">
    <div id="div">
        <button id="btn1">我是按钮</button>
    </div>
    <input type="checkbox"></div>

    <script>
        // 给输入框添加失去焦点事件
        document.querySelector('#txt').onblur = function (e) {
            console.log('失去焦点了', e.relatedTarget, this.classList.contains('dd'))
        }

        document.querySelector('#btn1').onclick = function () {

            alert ('按钮被点')
        }
        document.querySelector('#div').onclick = function () {

            alert ('div被点')
        }
    </script>
</body>
</html>